package com.xuecheng.comment.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xuecheng.comment.entity.Comment;
import com.xuecheng.comment.entity.data.StarRankData;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

import com.xuecheng.comment.entity.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author itcast
 */
public interface

CommentMapper extends BaseMapper<Comment> {

    Float selectAvgOfStar(Long targetId);

    @Select("select star_rank,count(star_rank) as star_count\n" +
            "from comment\n" +
            "where target_id = #{targetId}\n" +
            "group by star_rank")
    List<StarRankData> selectCountOfStar(@Param("targetId") Long targetId);
}
